#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

int GetMonth(int year, int month)
{
    int a[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
        a[month] = 29;
    return a[month];
}

int main()
{
    int year, month, day;
    cin >> year >> month >> day;
    for (int i = 1; i < month; i++)
    {
        day += GetMonth(year, i);
    }
    cout << day << endl;
}